<!DOCTYPE HTML>
<%@page import="shop.vo.ProTypeBean"%>
<%@page import="shop.vo.ProductBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="shop.factory.DAOFactory"%>
<%@page import="shop.vo.UserBean"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/head.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/foot.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/jquery-1.10.2.min.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="js/nav.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<title>主页</title>
</head>
<%
	if (session.getAttribute("login") == null) {
		session.setAttribute("login", false);
	}
	String str = (String)session.getAttribute("user");
	UserBean user = new UserBean();
	user.setUser_name(str);
	int id = DAOFactory.getIUserDAOInstance().findId(user);
%>
<body>
	<nav class="navbar navbar-default" role="navigation">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
		</div>
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li class="active"><a href="index.jsp">首页</a></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyOrder"> <img src="images/order.png" /> 我的订单
				</a></li>
				<li></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyCart"> <img src="images/car.png" /> 我的购物车
				</a></li>
				<li><a href="<%=request.getContextPath() %>/FavoriteServlet?action=MyFav"> <img src="images/favorite.png" /> 我的收藏
				</a></li>
				<li><a href="<%=request.getContextPath() %>/AddressServlet?action=MyAddress"> <img src="images/address.png" /> 我的地址簿
				</a></li>
			</ul>
			<div class="navbar-form navbar-left" role="search">
				<div class="form-group">
					<form action="<%=request.getContextPath() %>/ProductServlet?action=serch" method="post">
						<input type="text" class="form-control" placeholder="Search" name="reserch">
						<input type="submit" class="btn btn-primary" value="搜索" />
					</form>
				</div>
			</div>
			<ul class="nav navbar-nav navbar-right">
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=xinxi"><span id="huanying">欢迎光临，游客</span></a></li>
				<li><a href="./Login/login.jsp">登陆</a></li>
				<li><a href="./Login/regist.jsp">注册</a></li>
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=logout" class="active" onclick="return confirm('确认退出?')">退出</a></li>
			</ul>
		</div>
	</nav>
	<div class="container">
		<div class="row">
			<div class="col-lg-6">
				<img src="images/logo.png" /> <span>只有你想不到，没有你买不到</span>
			</div>
			<div class="col-lg-6">
				<ul>
					<li><img src="images/HEADERVIP1_gxf.png" /></li>
					<li><img src="images/HEADERVIP2_k3d.png" /></li>
					<li><img src="images/HEADERVIP3_wzf.png" /></li>
				</ul>
				<div class="mag_position">
					<img src="images/quality.png" />
				</div>
			</div>
		</div>
	</div>

	<!--导航开始-->
	<div class="container-fluid nav-bg">
		<div class="navbar-default navbar-wrapper"
			id="bs-example-navbar-collapse-1">
			<div class=" navbar-header">
				<div class="container">
					<ul class="nav nav-pills" id="textcolor">
						<li class="active"><a href="index.jsp">首页</a></li>
						<%
							List<Integer> list4 = DAOFactory.getIProTypeDAOInstance().listType();
							Iterator<Integer> it4 = list4.iterator();
							while (it4.hasNext()) {
								int b = it4.next();
								ProTypeBean ptype4 = DAOFactory.getIProTypeDAOInstance().find(b);
						%>
						<li><a href="<%=request.getContextPath()%>/ProductServlet?action=list&str=<%=ptype4.getPtype_name()%>"><%=ptype4.getPtype_name()%>专卖</a></li>
						<%
							}
						%>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<!--导航结束-->

	<!--轮播开始-->
	<div id="carousel-example-generic" class="carousel slide"
		data-ride="carousel">
		<!-- Indicators -->
		<ol class="carousel-indicators">
			<li data-target="#carousel-example-generic" data-slide-to="0"
				class="active"></li>
			<li data-target="#carousel-example-generic" data-slide-to="1"></li>
			<li data-target="#carousel-example-generic" data-slide-to="2"></li>
			<li data-target="#carousel-example-generic" data-slide-to="3"></li>
		</ol>
		<!-- Wrapper for slides -->
		<div class="carousel-inner" role="listbox">
			<div class="item active">
				<img src="images/rollerImage/1.jpg"></img>
			</div>
			<div class="item">
				<img src="images/rollerImage/2.jpg"></img>
			</div>
			<div class="item">
				<img src="images/rollerImage/3.jpg"></img>
			</div>
			<div class="item">
				<img src="images/rollerImage/4.jpg"></img>
			</div>
		</div>
		<!-- Controls -->
		<a class="left carousel-control" href="#carousel-example-generic"
			data-slide="prev"> <span
			class="glyphicon glyphicon-chevron-left "></span>
		</a> <a class="right carousel-control" href="#carousel-example-generic"
			data-slide="next"> <span
			class="glyphicon glyphicon-chevron-right"></span>
		</a>
	</div>
	<!--轮播结束-->

	<!--图片开始-->
	<div id="main">
		<div class="container">
			<div class="page-header" id="line">
				<h2>商品种类</h2>
			</div>
			<div class="row">
				<!--显示图片模式一开始-->
				<%
					List<Integer> li = DAOFactory.getIProTypeDAOInstance().listType();
					Iterator<Integer> iter2 = li.iterator();
					while (iter2.hasNext()) {
						int c = iter2.next();
						ProTypeBean ptype3 = DAOFactory.getIProTypeDAOInstance().find(c);
				%>
				<div class="col-sm-6 col-md-3">
					<div class="thumbnail Imagemodel_1">
						<a href="<%=request.getContextPath()%>/ProductServlet?action=list&str=<%=ptype3.getPtype_name()%>"><img src="<%=ptype3.getPtype_url()%>"></a>
						<div class="caption">
							<h3><%=ptype3.getPtype_name() %></h3>
						</div>
					</div>
				</div>
				<%
					}
				%>
				<!--显示图片模式一结束-->
			</div>
		</div>
	</div>
	<!--图片结束-->
	<div class="container">
		<div class="page-header">
			<h3>部分商品列举</h3>
		</div>
		<div class="row">
			<%
				List<Integer> list1 = DAOFactory.getIProductDAOInstance().listLei();
				Iterator<Integer> it1 = list1.iterator();
				while (it1.hasNext()) {
					int i = it1.next();
					ProductBean pro1 = DAOFactory.getIProductDAOInstance().find(i);
			%>
			<div class="col-sm-12 col-md-3">
				<a href="<%=request.getContextPath()%>/ProductServlet?action=xiangqing&proId=<%=pro1.getPro_id() %>" class="thumbnail"> <img
					src="<%=pro1.getPro_litlleimg() %>">
				</a>
				<div class="p-name">
					<a href="#"><%=pro1.getPro_name() %></a>
				</div>
				<div class="p-price">￥<%=pro1.getPrice() %></div>
			</div>
			<%
				}
			%>
		</div>
	</div>
	
	<div class="col-md-12">
		<img src="images/rollerImage/4.jpg" style="width: 100%;" />
	</div>
	
	<div class="container">
		<%
			List<Integer> list2 = DAOFactory.getIProTypeDAOInstance().listType();
			Iterator<Integer> it2 = list2.iterator();
			while (it2.hasNext()) {
				int id2 = it2.next();
				ProTypeBean ptype2 = DAOFactory.getIProTypeDAOInstance().find(id2);
				List<Integer> list3 = DAOFactory.getIProductDAOInstance().listLei(ptype2.getPtype_id());
				Iterator<Integer> it3 = list3.iterator();
		%>
		<div class="page-header">
			<h3>
				<a href="<%=request.getContextPath()%>/ProductServlet?action=list&str=<%=ptype2.getPtype_name()%>"><%=ptype2.getPtype_name() %>专卖</a>
			</h3>
		</div>
		<div class="row">
			<%
				while (it3.hasNext()) {
					int a = it3.next();
					ProductBean pro2 = DAOFactory.getIProductDAOInstance().find(a);
			%>
			<div class="col-sm-6 col-md-3">
				<a href="<%=request.getContextPath()%>/ProductServlet?action=xiangqing&proId=<%=pro2.getPro_id() %>" class="thumbnail"> <img
					src="<%=pro2.getPro_litlleimg()%>">
				</a>
				<div class="p-name">
					<a href="<%=request.getContextPath()%>/ProductServlet?action=xiangqing&proId=<%=pro2.getPro_id() %>"><%=pro2.getPro_name() %></a>
				</div>
				<div class="p-price">￥<%=pro2.getPrice() %></div>
			</div>
			<%
				}
			%>
		</div>
		<%
			}
		%>
	</div>

	<!--返回顶部开始-->

	<script type="text/javascript">
	$(document).ready(function(){

	$(window).scroll(function() {
		if ($(window).scrollTop() > 300) {
			$('#jump li:eq(0)').fadeIn(800);
		} else {
			$('#jump li:eq(0)').fadeOut(800);
		}
	});
	
	$("#top").click(function() {
		$('body,html').animate({
			scrollTop: 0
		},
		1000);
		return false;
	});

});
</script>
	<ul id="jump">
		<li style="display: none;"><a id="top" href="#top"></a></li>
		<li><a id="sina" href="http://weibo.com/" target="_blank"></a></li>
		<li><a id="weixin" href="javascript:void(0)"
			onmouseover="showEWM()" onmouseout="hideEWM()">
				<div id="EWM">
					<img src="images/qrcode.png" />
				</div>
		</a></li>
		<li><a id="reply" href="#" target="_blank" data-toggle="modal"
			data-target="#myModal"></a></li>
	</ul>

	<script type="text/javascript">
		function showEWM(){
			document.getElementById("EWM").style.display = 'block';
		}
		function hideEWM(){
			document.getElementById("EWM").style.display = 'none';
		} 
	</script>


	<!--返回顶部结束-->

	<!--底部开始-->
	<div class="container-fluid container-bg">
		<div class="row">
			<div class="col-md-3 foot-img">
				<img src="images/logo.png" class="image_logo" />
			</div>
			<div class="col-md-3">
				<h4 class="page-header">我们的宗旨</h4>
				<p class="foot-word">把第一次购买的顾客变成终身顾客</p>
				<p class="foot-word">服务比销售更重要</p>
				<p class="foot-word">服务大众 诚信网商</p>
			</div>
			<div class="col-md-3">
				<h4 class="page-header">售后服务</h4>
				<p class="foot-word">
					<img src="images/phone.png" />电话投诉：110
				</p>
				<p>
					<a href="#" class="btn btn-primary btn-success" data-toggle="modal"
						data-target="#myModal">客户反馈</a>
				</p>
			</div>
			<div class="col-md-3">
				<h4 class="page-header">联系我们</h4>
				<p class="foot-word">
					<img src="images/QQ.png" /> QQ：118283513、102358974
				</p>
				<p class="foot-word">
					<img src="images/phone.png" /> 电联：0668-8717664
				</p>
				<p class="foot-word">
					<img src="images/weixin.png" /> 微信号：LH12150603
				</p>
			</div>
			<div class="col-lg-12 text-center">
				<p>
					友情链接：<a href="http://www.taobao.com">淘宝</a> <a
						href="http://www.tmall.com/">天猫</a> <a href="http://www.vip.com/">唯品会
					</a><a href="http://www.jd.com/">京东</a> <a
						href="http://www.paipai.com/">拍拍网</a> <a
						href="http://www.mogujie.com/">蘑菇街</a> <br /> Power by Liang&Luo
					@版本号2014V0.0.01
				</p>
			</div>
		</div>
	</div>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h3 class="page-header font_style" id="myModalLabel">请留下您宝贵的意见\(^o^)/~</h3>
				</div>
				<div class="modal-body">
					<form action="<%=request.getContextPath() %>/MessageServlet?userId=<%=id %>" method="post">
						<textarea class="form-control" rows="3 " name="message"></textarea>
						<div class="modal-footer">
							<input class="btn btn-primary" type="submit" value="留言" />
							<input type="hidden" name="action" value="addMessage">
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!--底部结束-->
</body>
<script type="text/javascript">
<%
	if (session.getAttribute("user") != null) {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，<%=str%>";
<%
	} else {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，游客";
<%
	}
%>
</script>
</html>